#
# @lc app=leetcode.cn id=14 lang=python3
#
# [14] 最长公共前缀
#

# @lc code=start
from typing import List


class Solution:
    def longestCommonPrefix(self, strs: List[str]) -> str:
        ans = ''
        if strs:
            for i, match in enumerate(strs[0]):
                for s in strs[1:]:
                    if len(s) - 1 < i:
                        return ans
                    if s[i] != match:
                        return ans
                ans += match
        return ans


# @lc code=end
